package org.sosie2.mule.transformers;

import org.mule.transformers.AbstractTransformer;
import org.mule.umo.transformer.TransformerException;

import javax.xml.transform.OutputKeys;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;

import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.io.StringReader;

import org.apache.axis.Message;
import org.apache.axis.message.SOAPEnvelope;
import org.apache.axis.MessageContext;
import org.apache.axis.client.AxisClient;
import org.apache.axis.configuration.NullProvider;
import org.apache.axis.message.SOAPBody;
import org.apache.axis.utils.XMLUtils;
import org.w3c.dom.Document;
import org.xml.sax.InputSource;

public class StringToSOAPMessage extends AbstractTransformer
{
	private static final long serialVersionUID = 923698743238462983L;
	
	public StringToSOAPMessage()
	{
	    //super();
	    this.registerSourceType(String.class);
		this.setReturnClass(org.apache.axis.message.SOAPEnvelope.class);
	}
	public Object doTransform(Object src, String encoding) throws TransformerException
	{
		String text = (String)src;
		
		Message msg = new Message(text);
			
		try{
			System.out.println("Working...");
			
			return msg.getSOAPEnvelope();
		}
		catch(Exception e)
		{
			System.out.println("Exception in myTransformer: " + e.getMessage());
			return null;
		}
		
		
	}
	  
}